﻿ 
// Generated File 
// Generated: 13-6-2010 21:05:03
namespace PersonLookup.ViewModel
{
	public partial class Person : System.ComponentModel.INotifyPropertyChanged
	{
		#region Properties
		
		#region ID Property
		
		private int _iD;
		public int ID
		{
			get
			{
				return _iD;
			}
			set
			{
				if (_iD != value)
				{
					_iD = value;
					OnPropertyChanged("ID");
				}
			}
		}
		
		#endregion
		#region FirstName Property
		
		private string _firstName;
		public string FirstName
		{
			get
			{
				return _firstName;
			}
			set
			{
				if (_firstName != value)
				{
					_firstName = value;
					OnPropertyChanged("FirstName");
				}
			}
		}
		
		#endregion
		#region LastName Property
		
		private string _lastName;
		public string LastName
		{
			get
			{
				return _lastName;
			}
			set
			{
				if (_lastName != value)
				{
					_lastName = value;
					OnPropertyChanged("LastName");
				}
			}
		}
		
		#endregion

		#endregion	
		
		partial void MapLastNameFromModel(PersonLookup.PersonServiceReference.Person model);
		partial void MapLastNameToModel(PersonLookup.PersonServiceReference.Person model);
		public static Person FromModel(PersonLookup.PersonServiceReference.Person modelEntity)
		{
			var viewModelEntity = new PersonLookup.ViewModel.Person();
			viewModelEntity.ID = modelEntity.ID;
			viewModelEntity.FirstName = modelEntity.FirstName;
			viewModelEntity.MapLastNameFromModel(modelEntity);
			return viewModelEntity;
		}
		
		public PersonLookup.PersonServiceReference.Person ToModel()
		{
			var modelEntity = new PersonLookup.PersonServiceReference.Person();
			modelEntity.ID = this.ID;
			modelEntity.FirstName = this.FirstName;
			this.MapLastNameToModel(modelEntity);
			return modelEntity;
		}

	
		#region INotifyPropertyChanged Implementation
		
		public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

		protected void OnPropertyChanged(string propertyName)
		{
			System.ComponentModel.PropertyChangedEventHandler p = PropertyChanged;
			if (p != null)
			{
				p(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
			}
		}
		
		#endregion
	}
}

namespace PersonLookup.ViewModel
{
	public partial class PersonCollection : System.Collections.ObjectModel.ObservableCollection<PersonLookup.ViewModel.Person>
	{
		public static PersonCollection FromModel(System.Collections.Generic.IEnumerable<PersonLookup.PersonServiceReference.Person> modelCollection)
		{
			var viewModelCollection = new PersonCollection();
			foreach(var item in modelCollection)
			{
				viewModelCollection.Add(PersonLookup.ViewModel.Person.FromModel(item));
			}
			return viewModelCollection;
		}
		
		public System.Collections.Generic.IEnumerable<PersonLookup.PersonServiceReference.Person> ToModel()
		{
			var modelCollection = new System.Collections.Generic.List<PersonLookup.PersonServiceReference.Person>();
			foreach(var item in this)
			{
				modelCollection.Add(item.ToModel());
			}
			return modelCollection;
		}
	}
}

